package com.boilerCloud.controller.sys;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.boilerCloud.util.ValidateCode;

/**
 * @类功能说明：生成图形验证码
 * @类修改者：
 * @修改日期：
 * @修改说明：
 * @公司名称：杭州龙骞科技有限公司
 * @作者：qianfuqiang
 * @创建时间：2013-4-14 下午11:54:24
 * @版本：V1.0
 */
@Controller
public class HzlqswRandServlet {
	@RequestMapping(value = "/getRand")
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 设置响应的类型格式为图片格式
		response.setContentType("image/jpeg");
		// 禁止图像缓存。
		response.setHeader("Pragma", "no-cache");
		response.setHeader("Cache-Control", "no-cache");
		response.setDateHeader("Expires", 0);
		HttpSession session = request.getSession();
		ValidateCode vCode = new ValidateCode(102, 45, 4, 80);
		session.setAttribute("randcode", vCode.getCode());
		vCode.write(response.getOutputStream());
	}
}
